﻿#pragma once

#include <string>
#include <any>

namespace Server
{
    class ConfigForm : public System::Windows::Forms::Form
    {
    public:
        virtual ~ConfigForm()
        {
            delete components;
            delete SaveButton;
            delete configTabs;
            delete tabPage1;
            delete RelogDelayTextBox;
            delete label7;
            delete VersionCheckBox;
            delete VPathBrowseButton;
            delete VPathTextBox;
            delete label1;
            delete tabPage2;
            delete MaxUserTextBox;
            delete label5;
            delete TimeOutTextBox;
            delete label4;
            delete PortTextBox;
            delete label3;
            delete IPAddressTextBox;
            delete label2;
            delete VPathDialog;
            delete tabPage3;
            delete StartGameCheckBox;
            delete DCharacterCheckBox;
            delete NCharacterCheckBox;
            delete LoginCheckBox;
            delete PasswordCheckBox;
            delete AccountCheckBox;
            delete tabPage4;
            delete SaveDelayTextBox;
            delete label6;
            delete tabPage5;
            delete SafeZoneBorderCheckBox;
            delete SafeZoneHealingCheckBox;
            delete AllowArcherCheckBox;
            delete AllowAssassinCheckBox;
            delete label9;
            delete label8;
            delete Resolution_textbox;
            delete ServerVersionLabel;
            delete DBVersionLabel;
            delete label11;
            delete label10;
            delete groupBox1;
            delete label12;
            delete gameMasterEffect_CheckBox;
            delete HTTPIPAddressTextBox;
            delete label13;
            delete HTTPTrustedIPAddressTextBox;
            delete label14;
            delete label15;
            delete StartHTTPCheckBox;
            delete label16;
            delete lineMessageTimeTextBox;
            delete label17;
        }

        ConfigForm();

    private:
        void ConfigForm_FormClosed(std::any sender, FormClosedEventArgs *e);

        void SaveButton_Click(std::any sender, EventArgs *e);

    public:
        void Save();

    private:
        void IPAddressCheck(std::any sender, EventArgs *e);

        void CheckUShort(std::any sender, EventArgs *e);

        void VPathBrowseButton_Click(std::any sender, EventArgs *e);

        void Resolution_textbox_TextChanged(std::any sender, EventArgs *e);

        void tabPage3_Click(std::any sender, EventArgs *e);

        void SafeZoneBorderCheckBox_CheckedChanged(std::any sender, EventArgs *e);

        void SafeZoneHealingCheckBox_CheckedChanged(std::any sender, EventArgs *e);

        void HTTPIPAddressTextBox_TextChanged(std::any sender, EventArgs *e);


        void HTTPTrustedIPAddressTextBox_TextChanged(std::any sender, EventArgs *e);

        bool tryParseHttp();

        bool tryParseTrustedHttp();

        void StartHTTPCheckBox_CheckedChanged(std::any sender, EventArgs *e);


        /// <summary>
        /// Required designer variable.
        /// </summary>
        System::ComponentModel::IContainer *components = nullptr;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
    protected:
        void Dispose(bool disposing) override;

        #pragma region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
    private:
        void InitializeComponent();

        #pragma endregion

        System::Windows::Forms::Button *SaveButton;
        System::Windows::Forms::TabControl *configTabs;
        System::Windows::Forms::TabPage *tabPage1;
        System::Windows::Forms::TextBox *RelogDelayTextBox;
        System::Windows::Forms::Label *label7;
        System::Windows::Forms::CheckBox *VersionCheckBox;
        System::Windows::Forms::Button *VPathBrowseButton;
        System::Windows::Forms::TextBox *VPathTextBox;
        System::Windows::Forms::Label *label1;
        System::Windows::Forms::TabPage *tabPage2;
        System::Windows::Forms::TextBox *MaxUserTextBox;
        System::Windows::Forms::Label *label5;
        System::Windows::Forms::TextBox *TimeOutTextBox;
        System::Windows::Forms::Label *label4;
        System::Windows::Forms::TextBox *PortTextBox;
        System::Windows::Forms::Label *label3;
        System::Windows::Forms::TextBox *IPAddressTextBox;
        System::Windows::Forms::Label *label2;
        System::Windows::Forms::OpenFileDialog *VPathDialog;
        System::Windows::Forms::TabPage *tabPage3;
        System::Windows::Forms::CheckBox *StartGameCheckBox;
        System::Windows::Forms::CheckBox *DCharacterCheckBox;
        System::Windows::Forms::CheckBox *NCharacterCheckBox;
        System::Windows::Forms::CheckBox *LoginCheckBox;
        System::Windows::Forms::CheckBox *PasswordCheckBox;
        System::Windows::Forms::CheckBox *AccountCheckBox;
        System::Windows::Forms::TabPage *tabPage4;
        System::Windows::Forms::TextBox *SaveDelayTextBox;
        System::Windows::Forms::Label *label6;
        System::Windows::Forms::TabPage *tabPage5;
        System::Windows::Forms::CheckBox *SafeZoneBorderCheckBox;
        System::Windows::Forms::CheckBox *SafeZoneHealingCheckBox;
        System::Windows::Forms::CheckBox *AllowArcherCheckBox;
        System::Windows::Forms::CheckBox *AllowAssassinCheckBox;
        System::Windows::Forms::Label *label9;
        System::Windows::Forms::Label *label8;
        System::Windows::Forms::TextBox *Resolution_textbox;
        System::Windows::Forms::Label *ServerVersionLabel;
        System::Windows::Forms::Label *DBVersionLabel;
        System::Windows::Forms::Label *label11;
        System::Windows::Forms::Label *label10;
        System::Windows::Forms::GroupBox *groupBox1;
        System::Windows::Forms::Label *label12;
        System::Windows::Forms::CheckBox *gameMasterEffect_CheckBox;
        System::Windows::Forms::TextBox *HTTPIPAddressTextBox;
        System::Windows::Forms::Label *label13;
        System::Windows::Forms::TextBox *HTTPTrustedIPAddressTextBox;
        System::Windows::Forms::Label *label14;
        System::Windows::Forms::Label *label15;
        System::Windows::Forms::CheckBox *StartHTTPCheckBox;
        System::Windows::Forms::Label *label16;
        System::Windows::Forms::TextBox *lineMessageTimeTextBox;
        System::Windows::Forms::Label *label17;
    };
}
